package com.bizhibihui.ordermeal.component;

import com.bizhibihui.ordermeal.entity.BizCategory;
import com.bizhibihui.ordermeal.entity.BizTags;
import com.bizhibihui.ordermeal.service.BizCategoryService;
import com.bizhibihui.ordermeal.service.BizTagsService;
import com.bizhibihui.ordermeal.util.CoreConst;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * thymeleaf调用后台的工具类
 *
 * @author Linzhaoguan
 * @version V1.0
 * @date 2019年9月11日
 */
@Component("module")
@AllArgsConstructor
public class ModuleService {

    private final BizCategoryService bizCategoryService;
    private final BizTagsService bizTagsService;

    public Object get(String moduleName) {
        switch (moduleName) {
            //分类
            case "categoryList":
                BizCategory bizCategory = new BizCategory();
                bizCategory.setStatus(CoreConst.STATUS_VALID);
                return bizCategoryService.selectCategories(bizCategory);
            //标签
            case "tagList":
                return bizTagsService.selectTags(new BizTags());
            default:
                return null;
        }
    }
}
